package com.nc.shop.service.model.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 创建人:    xvzhe
 * 创建时间:
 * 修改时间:
 * 版本:      v1.0
 */
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@DynamicInsert
@DynamicUpdate
@ApiModel("订单记录")
public class OrderEntity {
    @Id
    @GeneratedValue(generator = "NumberIdProduce")
    @GenericGenerator(name = "NumberIdProduce", strategy = "com.plug.idProduce.NumberIdProduce")
    private String id;

    @Column
    private String name;

    @ApiModelProperty("0是订单，1：是订单项")
    @Column(columnDefinition = "int default 0")
    Integer type;

    @Column
    String parentId;

    @Column
    BigDecimal money;

    @Column
    Integer number;

    @ApiModelProperty("订单状态。-3是已退货。-2是退货中，-1是取消。0，是未付款，1是已经付款，2是邮寄中，3是已收货，4：是已完成")
    @Column
    Integer status;

    @Column
    String shopId;

    @Column
    String userId;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @CreatedDate
    @Column
    private Date createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @LastModifiedDate
    @Column
    private Date modifiedTime;
}
